﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;
namespace GUI
{
    public partial class frmQuanLyDatMon : Form
    {
        public frmQuanLyDatMon()
        {
            InitializeComponent();
            plTimKiem.Visible = false;
            plNgay.Visible = false;
        }
        private void Hien()
        {
            if (rdKhachHang.Checked == true)
            {
                lbChon.Text = "Khách Hàng:";
                plTimKiem.Visible = true;
                plNgay.Visible = false;
                plNgay.Hide();
                plTimKiem.Show();
            }
            if (rdNhanVien.Checked == true)
            {
                lbChon.Text = "Nhân Viên:";
                plTimKiem.Visible = true;
                plNgay.Visible = false;
                plNgay.Hide();
                plTimKiem.Show();
            }
            if (rdMonAn.Checked == true)
            {
                lbChon.Text = "Mã Đặt Món:";
                plTimKiem.Visible = true;
                plNgay.Visible = false;
                plNgay.Hide();
                plTimKiem.Show();
            }
            if (rdTinhTrang.Checked == true)
            {
                lbChon.Text = "Tình Trạng:";
                plTimKiem.Visible = true;
                plNgay.Visible = false;
                plNgay.Hide();
                plTimKiem.Show();
            }
            if (rdNgay.Checked == true)
            {
                plTimKiem.Visible = false;
                plNgay.Visible = true;
                plNgay.Show();
                plTimKiem.Hide();
            }
            if (rdTatCa.Checked == true)
            {
                plTimKiem.Visible = false;
                plNgay.Visible = false;
                plNgay.Hide();
                plTimKiem.Hide();
            }
        }
        private void btSua_Click(object sender, EventArgs e)
        {
            dgvDanhSach.Enabled = true;
        }

        private void frmQuanLyDatMon_Load(object sender, EventArgs e)
        {
            rdTatCa.Checked = true;
            DanhSachDonHang();
            Hien();
        }

        private void rdTatCa_CheckedChanged(object sender, EventArgs e)
        {
            Hien();
        }

        private void rdNgay_CheckedChanged(object sender, EventArgs e)
        {
            Hien();
        }

        private void rdNhanVien_CheckedChanged(object sender, EventArgs e)
        {
            Hien();
        }

        private void rdKhachHang_CheckedChanged(object sender, EventArgs e)
        {
            Hien();
        }

        private void rdTinhTrang_CheckedChanged(object sender, EventArgs e)
        {
            Hien();
        }

        private void rdMonAn_CheckedChanged(object sender, EventArgs e)
        {
            Hien();
        }

        private void btThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void DanhSachDonHang()
        {
            List<DatMonDTO> ds = new List<DatMonDTO>();
            DatMonBUS bus = new DatMonBUS();
            ds = bus.DanhSachDonHang();

            for (int i = 0; i < ds.Count; i++)
            {
                NhanVienBUS busnv = new NhanVienBUS();
                NhanVienDTO dtonv=busnv.LayThongTinNV(ds[i].MaNVQL);
                TinhTrangBUS bustt = new TinhTrangBUS();

                string tinhtrang = bustt.TenTinhTrang(ds[i].MaTT);
                dgvDanhSach.Rows.Add((i + 1), ds[i].MaDM, ds[i].MaKH,dtonv.TenNV , ds[i].NgayGioDM, tinhtrang, ds[i].TongTien);
            }

        }

    }
}
